package com.risk.web.controller.tk;

import com.risk.common.core.controller.BaseController;
import com.risk.common.core.domain.AjaxResult;
import com.risk.common.core.page.TableDataInfo;
import com.risk.kernel.service.TkTaskCaseExecuteServiceI;
import com.risk.kernel.vo.TkTaskCaseInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: Liwen
 * @createTime: 2025/1/23
 * @description:
 */
@RestController
@RequestMapping(value = "/tk/task/case")
public class TkTaskCaseExecuteController extends BaseController {
    @Autowired
    private TkTaskCaseExecuteServiceI executeService;

    /**
     * 执行测试用例
     *
     * @param caseId
     * @param caseName
     * @return
     */
    @GetMapping(value = "/execute/add")
//    @PreAuthorize("@ss.hasPermi('tk:case:execute')")
    public AjaxResult executeAdd(@RequestParam String caseId, @RequestParam String caseName) {
        return executeService.executeAdd(caseId, caseName);
    }

    /**
     * 实时查询结果
     *
     * @return
     */
    @GetMapping(value = "/getExecuteList")
    public TableDataInfo getExecuteList() {
        List<TkTaskCaseInfoVo> list = executeService.getExecuteList();
        return getDataTable(list);
    }

    /**
     * 用例结果是否执行完成
     * @param caseId
     * @return
     */
    @GetMapping(value = "/getExecuteResultIsFinish/{caseId}")
    public AjaxResult getExecuteResultIsFinish(@PathVariable String caseId) {
        return success(executeService.getExecuteResultIsFinish(caseId));
    }


}
